﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace CustomersSuppliersWebApplication
{
    public partial class LoginMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.RadAjaxLoadingPanelDefault.Skin = this.RadSkinManagerDefault.Skin;
        }

        //save dock state in cookies
        protected void RadDockLayoutDefault_SaveDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)
        {
            HttpCookie dockState = Page.Response.Cookies.Get("MyApplicationDockStates");
            if (dockState == null)
            {
                dockState = new HttpCookie("MyApplicationDockStates");
                Page.Response.Cookies.Add(dockState);
            }
            List<DockState> stateList = ((RadDockLayout)sender).GetRegisteredDocksState();
            StringBuilder serializedList = new StringBuilder();
            for (int i = 0; i < stateList.Count; i++)
            {
                serializedList.Append(stateList[i].ToString());
                serializedList.Append("|");
            }
            dockState.Expires = DateTime.Today.AddYears(10);
            dockState.Value = serializedList.ToString();
        }
        //save dock state from cookies
        protected void RadDockLayoutDefault_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)
        {
            HttpCookie dockState = Page.Request.Cookies.Get("MyApplicationDockStates");
            if (dockState != null)
            {
                string serializedList = dockState.Value;
                if (serializedList != null)
                {
                    string[] states = serializedList.Split('|');
                    for (int i = 0; i < states.Length; i++)
                    {
                        DockState state = DockState.Deserialize(states[i]);
                        e.Positions[state.UniqueName] = state.DockZoneID;
                        e.Indices[state.UniqueName] = state.Index;
                    }
                }
            }
        }

    }
}